package com.tuoren.forward.service;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.tuoren.forward.entity.Log;
import com.tuoren.forward.entity.dto.LogDto;
import com.tuoren.forward.entity.req.LogSearchReq;
import com.tuoren.forward.mapper.LogMapper;
import com.tuoren.forward.util.ResultPage;

@Service
public class LogService {

	@Autowired
	LogMapper logMapper;
	
	/**
	 * @title 查询日志
	 * @param req
	 * @return ResultPage<Log>
	 */
	public ResultPage<Log> search(LogSearchReq req){
		Page<Object> page = PageHelper.startPage(req.getPage(), req.getSize());
		LogDto dto = new LogDto();
		BeanUtils.copyProperties(req, dto);
		List<Log> logs = logMapper.select(dto);
		return ResultPage.success(logs, page.getTotal());
	}
}
